<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head>
        <title>Sistema gerenciador escolar</title>
        <link type="text/css" rel="stylesheet" href="dot-luv/skin.css"/>
    </h:head>
    <h:body>
        <p:layout fullPage="true">
            <p:layoutUnit position="left" width="200" header="Atividades" resizable="true" closable="true" collapsible="true">
                <h:form prependId="false">
                    <p:commandLink value="Nova Disciplina" actionListener="#{disciplinaManagedBeans.prepararAdicionarDisciplina}" update="infosDisciplina" oncomplete="dialogGerDisciplina.show()"/>
                </h:form>
            </p:layoutUnit>
            <p:layoutUnit position="center">
                <h1>Gerenciador Escolar</h1>
                <br/>
                <h:form prependId="false">
                    <p:dataTable id="tabela" var="disciplina" value="#{disciplinaManagedBeans.listarDisciplinas}">
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Nome"/>
                            </f:facet>
                            <h:outputText value="#{disciplina.nome}" />
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Horário"/>
                            </f:facet>
                            <h:outputText value="#{disciplina.horarioMateria}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Situação"/>
                            </f:facet>
                            <h:outputText value="#{disciplina.situacao}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Alterar"/>
                            </f:facet>
                            <p:commandButton actionListener="#{disciplinaManagedBeans.prepararAlterarDisciplina}" value="Alterar" update="infosDisciplina" oncomplete="dialogGerDisciplina.show()"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Excluir"/>
                            </f:facet>
                            <h:commandLink action="#{disciplinaManagedBeans.excluirDisciplina}" value="Excluir"/>
                        </p:column>
                    </p:dataTable>
                </h:form>
            </p:layoutUnit>
        </p:layout>

        <p:dialog header="Sistema de gerenciamento escolar" widgetVar="dialogGerDisciplina"  resizable="false" modal="true" showEffect="slide" width="500">
            <h:form prependId="false">
                <h:panelGrid id="infosDisciplina" columns="2" style="margin-bottom:10px">

                    <h:outputLabel for="nome" value="Nome:" />
                    <h:inputText id="nome" value="#{disciplinaManagedBeans.disciplina.nome}"/>

                    <h:outputLabel for="horario" value="Horário:" />
                    <p:inputMask size="6" id="horario" value="#{disciplinaManagedBeans.disciplina.horarioMateria}" mask="99:99" requiredMessage="Campo obrigatório não preenchido"/>
                    
                    <h:outputLabel for="situacao" value="Situação:" />
                    <h:selectOneMenu id="situacao" value="#{disciplinaManagedBeans.disciplina.situacao}">
                        <f:selectItem itemLabel="Ativo" itemValue="1"/>
                        <f:selectItem itemLabel="Inativo" itemValue="2"/>
                    </h:selectOneMenu>

                    <p:commandButton update="tabela" oncomplete="dialogGerDisciplina.hide();" actionListener="#{disciplinaManagedBeans.adicionarDisciplina}" value="Inserir Disciplina"/>
                    <p:commandButton update="tabela" oncomplete="dialogGerDisciplina.hide();" actionListener="#{disciplinaManagedBeans.alterarDisciplina}" value="Alterar Disciplina"/>

                </h:panelGrid>
            </h:form>
        </p:dialog>

    </h:body>
</html>